<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class My_orders extends MIS_Controller {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/my-orders
	 *	- or -  
	 * 		http://example.com/my_orders
	 *	- or -  
	 * 		http://example.com/my-orders/index
	 *	- or -  
	 * 		http://example.com/my_orders/index
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	public function index()
	{
		if(!$this->is_loggedin) 
		{
			$this->session->set_flashdata('error_mesg',"Please login to see orders.");
			$this->redirectAfterLogin('my-orders');
			redirect('login');
		}
		$this->loadViewData['orderArray'] = array();
		$this->load->model('m_order');
		$res = $this->m_order->getOrdersOfUserId($this->session->userdata('id_user'));
		if($res->num_rows())
		{
			foreach ($res->result() as $info)
			{
				$data = array();
				$data['cust_order_id'] = $info->cust_order_id;
				$data['date_of_order'] = $info->date_of_order;
				$data['qty'] = $info->qty;
				$data['status'] = $info->status;
				$data['price'] = $info->price;
				$data['status'] = $info->status;
				$data['book_name'] = $info->Name;
				$this->loadViewData['orderArray'][$info->cust_order_id][] = $data;
				
			}
		}
		$this->loadViewData['banner_inc'] = false;
		$this->loadViewData['search_inc'] = false;
		$this->loadViewData['upper_footer_inc'] = false;
		$this->loadViewData['viewFile'] = 'v_my_orders';
		$this->load->view('layout', $this->loadViewData);
	}
}

/* End of file welcome.php */
/* Location: ./application/controllers/my_orders.php */
